<template>
	<view class="tea-map-detail-app">
		<map @tap="onMapTap" style="width: 100%; height: 100%;" :latitude="map.latitude" :longitude="map.longitude" id="teaMap" ref="teaMap" :markers="map.covers" @markertap="markertap">
		</map>
	</view>
</template>

<script>
	import util from '@/libs/util.js'
	import globalConfig from '../../../config'
	const baseHttp = globalConfig.API_HOST
		
	export default {
	    data() {
	        return {
				baseHttp: baseHttp,
				teaHouseId: '',
				map: {
					latitude: 39.910925,
					longitude: 116.413384,
					covers: [
						
					]
				},
				teaHouse: {
					teaHouseId: null,
					address: "",
					des: "",
					images: "",
					joinTime: "",
					lat: "",
					lon: "",
					name: "",
					remark: "",
					teaHouseId: "",
					tel: ""
				},
				wxCode: "",
				teaConfig: {
					deposit: "",
					vipMoney: "",
					superVipTimes: "",
					subMemberLimit: "",
					remark: ""
				},
				listData: {
					items: [

					]
				}
	        }
	    },
		onLoad(params) {
			this.teaHouse.teaHouseId = params.id;
			console.log("参数");
			console.log(params);
			//this.roomId = params.roomId;
			//console.log("teaHouseId:"+this.teaHouseId);
			//console.log("roomId:"+this.roomId);
		},
		onShow() {
			//this.getDataList();	
			//this.getDataList();
			//this.getConfigInfo();
			//this.getWxCode();
			this.getTeaHouseInfo();
		},
		components: {
			
		},
		computed: {

		},
	    methods: {
			...util,
			getTeaHouseInfo() {
				console.log("house info");
				this.$api.post('/teaHouse/getById',
				  {
					teaHouseId: this.teaHouse.teaHouseId
				  }
				).then((response) => {
				  if (response.ret===1) {
					this.teaHouse = response.data
					this.map.latitude = this.teaHouse.lat;
					this.map.longitude = this.teaHouse.lon;
					
					this.map.covers.push({
						id: this.teaHouse.teaHouseId,
					    latitude: this.teaHouse.lat,
					    longitude: this.teaHouse.lon,
						title: this.teaHouse.name,
						width:50,
						height:50,
					    iconPath: '../../../static/point.png'
					});
					
				  } else {
					this.$Message.error(response.msg)
				  }
				});
			},
			markertap(event) {
				//console.log(tapPosition);
				//tapPosition.detail.latitude
				//this.map.covers = [];
				this.goPage('/pages/tea/default/room?teaHouseId='+event.detail.markerId)
				//this.getMapTeaHouse(tapPosition.detail.longitude,tapPosition.detail.latitude);
			},
			goPage(url) {
				uni.navigateTo({url: url})
			},
	    }
	}
</script>



<style lang="scss">
	page{
		height: 100%;
	}
	.tea-map-detail-app{
		height:100%;
		width:100%;
	}
	
</style>

